home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / d.t.p / utils / propage / donsgenies / donsgenies.lha / Don'sGenies / GridPositionFromBox.pprx < prev    next >
Text File  |  1993-05-25  |  2KB  |  74 lines

  1. /* This Genie sets up a grid to match the position of a box, with snap enabled. If either a side or the top is selected, the result resembles a snap-to guide line. Note that when you move a box only the left or top side will snap, and rotated boxes do not snap properly. Ctrl-S switches snap on and off.
  2. Written by Don Cox  © Feb 93. Not public domain. All rights reserved. */
  3.  
  4.  
  5. signal on error
  6. signal on syntax
  7. address command
  8. call SafeEndEdit.rexx()
  9. call ppm_AutoUpdate(0)
  10. cr="0a"x
  11.  
  12. trace n
  13. currentunits = ppm_GetUnits()
  14. box     = ppm_ClickOnBox("  Click on box for grid size.")
  15. if box  = 0 then exit_msg("No box selected")
  16. gsize = ppm_GetGridSize()
  17. gwidth = word(gsize,1)
  18. gheight = word(gsize,2)
  19.  
  20. call ppm_SaveText("ram:gridsize",gsize)
  21. size = ppm_GetBoxSize(box)
  22. width = word(size,1)
  23. height = word(size,2)
  24. where = ppm_GetBoxPosition(box)
  25. xpos = word(where,1)
  26. ypos = word(where,2)
  27. if xpos>2 then do
  28.     xnum = xpos%2.0
  29.     xspacing = xpos/xnum
  30.     end
  31. if ypos>2 then do
  32.     ynum = ypos%2.0
  33.     yspacing = ypos/ynum
  34.     end
  35.  
  36. choice = ppm_Inform(3,"Set Grid position to match box...","Right","Top","Left")
  37. select
  38.     when choice = 0 then do
  39.         if (xpos+width)>2 then do
  40.             xnum = (xpos+width)%2
  41.             xspacing = (xpos+width)/xnum
  42.             end
  43.         call ppm_SetGridSize(xspacing,0.01)
  44.         end
  45.     when choice = 1 then call ppm_SetGridSize(0.01,yspacing)
  46.     otherwise call ppm_SetGridSize(xspacing,0.01)
  47.     end
  48.  
  49.  
  50. call ppm_SetGrid(1)
  51.  
  52. call ppm_SetGridSnap(1)
  53.  
  54. call exit_msg()
  55.  
  56. end
  57.  
  58. error:
  59. syntax:
  60.     do
  61.     exit_msg("Genie failed due to error: "errortext(rc))
  62.     end
  63.  
  64. exit_msg:
  65.     do
  66.     parse arg message
  67.     if message ~= "" then
  68.     call ppm_Inform(1,message)
  69.     call ppm_ClearStatus()
  70.     call ppm_AutoUpdate(1)
  71.     exit
  72.     end
  73.  
  74.